﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ocean.OceanFramework.BusinessEntity;
using Ocean.OceanFramework.StringFormatting;
using Ocean.OceanFramework.Validation;
using System.ComponentModel; 

namespace BusinessEntityObjects
{
    
    public class Contact  : BusinessEntityBase
    {

        #region " Declarations "

        private Nullable<System.DateTime> _datBirthday;
        private int _intId;
        private int _intNumberOfComputers;
        private string _strBlogURL = string.Empty;
        private string _strComment = string.Empty;
        private string _strFeedURL = string.Empty;
        private string _strFirstName = string.Empty;
        private string _strLastName = string.Empty;

        #endregion

        #region " Properties "

        public Nullable<System.DateTime> Birthday
        {
            get { return _datBirthday; }
            set { base.SetPropertyValue("Birthday", ref _datBirthday, value); }
        }

        [CharacterCasingFormatting(CharacterCasing.LowerCase)]
        [StringLengthValidator(100)]
        [RegularExpressionValidator(RegularExpressionPatternType.URL, RequiredEntry.No)]
        public string BlogURL
        {
            get { return _strBlogURL; }
            set { base.SetPropertyValue("BlogURL", ref _strBlogURL, value); }
        }

        [StringLengthValidator(50)]
        public string Comment
        {
            get { return _strComment; }
            set { base.SetPropertyValue("Comment", ref _strComment, value); }
        }

        [StringLengthValidator(100)]
        [RegularExpressionValidator(RegularExpressionPatternType.URL, RequiredEntry.No)]
        public string FeedURL
        {
            get { return _strFeedURL; }
            set { base.SetPropertyValue("FeedURL", ref _strFeedURL, value); }
        }

        [StringLengthValidator(1, 30)]
        [CharacterCasingFormatting(CharacterCasing.ProperName)]
        public string FirstName
        {
            get { return _strFirstName; }
            set { base.SetPropertyValue("FirstName", ref _strFirstName, value); }
        }

        [CompareValueValidator(ComparisonType.GreaterThan, 0, RequiredEntry.Yes, PropertyFriendlyName = "Contact Id", RuleSet = "Update|Delete")]
        public int Id
        {
            get { return _intId; }
            set { base.SetPropertyValue("Id", ref _intId, value); }
        }

        [CharacterCasingFormatting(CharacterCasing.ProperName)]
        [StringLengthValidator(1, 30)]
        public string LastName
        {
            get { return _strLastName; }
            set { base.SetPropertyValue("LastName", ref _strLastName, value); }
        }

        [CompareValueValidator(ComparisonType.GreaterThanEqual, 0, RequiredEntry.No)]
        public int NumberOfComputers
        {
            get { return _intNumberOfComputers; }
            set { base.SetPropertyValue("NumberOfComputers", ref _intNumberOfComputers, value); }
        }

        #endregion

        #region " Constructor "

        public Contact()
        {
        }

        #endregion

        #region " Methods "

        protected override void AddSharedBusinessValidationRules(Ocean.OceanFramework.Validation.ValidationRulesManager mgrValidation)
        {
            mgrValidation.AddRule(ComparisonValidationRules.CompareValueRule, new CompareValueRuleEventArgs(ComparisonType.LessThanEqual, RequiredEntry.No, System.DateTime.Now, string.Empty, "Birthday", "Birthday", string.Empty), RuleType.Shared);
        }
    }

        #endregion 

}
